package com.csp.main.controller;


import com.csp.common.utils.R;
import com.csp.main.utils.JWTUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Classname TestController
 * @Description done
 * @Date 2022/6/4 19:46
 * @Created by csp
 */
@RestController
public class TestController {

    @GetMapping("/hi")
    public R test(HttpServletRequest request, HttpServletResponse response){
        String token = request.getHeader(JWTUtils.USER_LOGIN_TOKEN);
        String sub = JWTUtils.validateToken(token);
        return R.ok().data("id",sub);
    }
}
